import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
export default defineConfig({
	base: "./",
	server: {
		https: false,
		port: 8080,
		open: true,
		proxy: {
			"/back": {
				target: "http://127.0.0.1:8085/back",
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/back/, ""),
			},
		},
	},
	plugins: [
		vue(),
		AutoImport({
			imports: ["vue", "vue-router", "pinia"],
			eslintrc: {
				enabled: true,
				filepath: "./.eslintrc-auto-import.json",
				globalsPropValue: true,
			},
			resolvers: [ElementPlusResolver()],
			dts: false,
		})
	],
	resolve: {
		alias: {
			"@": fileURLToPath(new URL("./src", import.meta.url)),
			"@comp": fileURLToPath(new URL("./src/components", import.meta.url)),
		},
		extensions: [".js", ".mjs", ".vue"],
	},
	css: {
		preprocessorOptions: {
			scss: {
				javascriptEnabled: true,
				additionalData: `@import "@/style/color.scss";`,
			},
		},
	},
});
